Repository navigation
fix(size): Stop named __cstring symbols from absorbing following literals - #759
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…rals In __cstring, literals are mostly unnamed, so the distance-to-next-symbol heuristic charged every following literal to the preceding named constant (e.g. a 17-byte hex lookup table reported as ~79 KB). Clamp the size of a symbol in a C-string-literal section to its NUL terminator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #678
Root cause.
MachOSymbolSizes._symbol_sizessizes a symbol as the distance to the next symbol in the same section (or to the section end). Literals in__TEXT,__cstringmostly have no symbol-table entry, so a named constant such asstatic const char hex[] = "0123456789abcdef";was charged for every unnamed literal after it (17 bytes reported as ~78 KB in the issue).Fix. For symbols in a C-string-literal section (
TYPE.CSTRING_LITERALS), the end is clamped to the NUL terminator of the literal that starts at the symbol, still capped by the next symbol / section end. Other sections keep the existing heuristic. The unrelated literals are no longer attributed to the named symbol.Test. New
tests/unit/size/test_macho_symbol_sizes.pywith a synthetic__cstringsection: the named literal gets 17 bytes instead of the whole section (red before, green after), two named literals keep their own sizes, and a__textsymbol is unchanged.Not changed: the
C Functionslabel for non-function symbols mentioned in the issue; that is a separate presentation change.tests/integration/sizehas 9 failures that also fail identically onmainin the environment used for this change (sizes/reference fixtures,strip, Android), so they are unrelated.This change was prepared with the assistance of an AI coding agent (Claude).